package com.ly.lypopupwindowdemo.activity;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.ly.lypopupwindowdemo.R;

import butterknife.BindView;

public class DHLianxiActivity extends AppCompatActivity {


    TextView tv1;

    private TextView tv2;

    private TextView tv3;

    private TextView tv4,tv5;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dhlianxi);

        tv1 = (TextView) findViewById(R.id.tv1);
        tv2 = (TextView) findViewById(R.id.tv2);
        tv3 = (TextView) findViewById(R.id.tv3);
        tv4 = (TextView) findViewById(R.id.tv4);
        tv5 = (TextView) findViewById(R.id.tv5);

        initDH();
    }

    private void initDH() {
        Animator animator1 = AnimatorInflater.loadAnimator(this,R.animator.updown_animatorset);
        animator1.setTarget(tv1);
        animator1.start();



        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tv2.setVisibility(View.VISIBLE);
                Animator animator2 = AnimatorInflater.loadAnimator(DHLianxiActivity.this,R.animator.updown_animatorset);
                animator2.setTarget(tv2);
                animator2.start();
            }
        },500);



        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                tv3.setVisibility(View.VISIBLE);
                Animator animator3 = AnimatorInflater.loadAnimator(DHLianxiActivity.this,R.animator.updown_animatorset);
                animator3.setTarget(tv3);
                animator3.start();
            }
        },1000);

        scaleAnim1();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                scaleAnim2();
            }
        },900);


        Animator animator5 = AnimatorInflater.loadAnimator(this,R.animator.translatealpha_animatorset);
        animator5.setTarget(tv5);
        animator5.start();

    }

    private void scaleAnim2() {
        ObjectAnimator animator = ObjectAnimator.ofFloat(tv4, "scaleX", 1.3f, 1f);
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(tv4, "scaleY", 1.3f, 1f);
        AnimatorSet set = new AnimatorSet();
        set.play(animator).with(animator2);
        set.setDuration(200);
        set.start();

    }

    private void scaleAnim1() {
        ObjectAnimator animator = ObjectAnimator.ofFloat(tv4, "scaleX", 0f, 1.3f);
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(tv4, "scaleY", 0f, 1.3f);
        AnimatorSet set = new AnimatorSet();
        set.play(animator).with(animator2);
        set.setDuration(900);
        set.start();
    }

}
